#! /bin/sh

#
# Check VTOP translation for RISC-V Sv48 (4-level paging).
#

pf="riscv64:12,9,9,9,9"

ptes="-e 0x0000:0x401"		# level3[0] -> 1000
ptes="$ptes -e 0x0008:0x1401"	# level3[1] -> 5000
ptes="$ptes -e 0x0010:0x600000000f" # level3[2] -> 18000000000 (512G)
ptes="$ptes -e 0x1000:0x801"	# level3[0] -> level2[0] -> 2000
ptes="$ptes -e 0x1010:0xf000000f" # level3[0] -> level2[2] -> 3c0000000 (1G)
ptes="$ptes -e 0x2000:0xc01"	# level3[0] -> level2[0] -> level1[0] -> 3000
ptes="$ptes -e 0x2008:0x1001"	# level3[0] -> level2[0] -> level1[1] -> 4000
ptes="$ptes -e 0x2010:0x38000f"	# level3[0] -> level2[0] -> level1[1] -> 4000 -> e00000 (2M)
ptes="$ptes -e 0x3000:0x280f"	# level3[0] -> level2[0] -> level1[0] -> level0[0] -> a000
ptes="$ptes -e 0x3008:0x2c0f"	# level3[0] -> level2[0] -> level1[0] -> level0[1] -> b000
ptes="$ptes -e 0x4800:0x300f"	# level3[0] -> level2[0] -> level1[1] -> level0[256] -> c000
ptes="$ptes -e 0x5010:0x1801"	# level3[1] -> level2[2] -> 6000
ptes="$ptes -e 0x6018:0x1c01"	# level3[1] -> level2[2] -> level1[3] -> 7000
ptes="$ptes -e 0x7020:0x2000000000340f"	# level3[1] -> level2[2] -> level1[3] -> level0[4] -> 8000000000d000

list="0x123:0xa123"		# VPN[3]=0 VPN[2]=0 VPN[1]=0 VPN[0]=0
list="$list 0x1234:0xb234"	# VPN[3]=0 VPN[2]=0 VPN[1]=0 VPN[0]=1
list="$list 0x300567:0xc567"	# VPN[3]=0 VPN[2]=0 VPN[1]=1 VPN[0]=256
list="$list 0x808060489a:0x8000000000d89a" # VPN[3]=1 VPN[2]=2 VNP[1]=3 VPN[0]=4
list="$list 0x523456:0xf23456"	# VPN[3]=0 VPN[2]=0 VPN[1]=2 (2M)
list="$list 0xa1234567:0x3e1234567" # VPN[3]=0 VPN[2]=2 (1G)
list="$list 0x123456789ab:0x1a3456789ab" # VPN[3]=2 (512G)

. "$srcdir"/addrxlat-common
